<template>
  <el-dialog :visible.sync="show" width="350px" title="删除课程">
    <el-row>
      <span>你确定要删除改课程吗</span>
    </el-row>
    <template slot="footer">
      <el-button @click="show=false">取消</el-button>
      <el-button type="danger" @click="deleteItem">确认</el-button>
    </template>
  </el-dialog>
</template>

<script>
import CApi from '../../api/Course.js';
export default {
  props: {
    id: Number,
    visible: Boolean
  },
  data() {
    return {
      show: false
    };
  },
  watch: {
    visible: function(val) {
      this.show = val;
    },
    show: function(val) {
      this.$emit("update:visible", val);
    }
  },
  methods: {
    deleteItem() {
      //todo
      this.show = false;
      this.axios.delete(CApi.delete,{params:{id:this.id}}).then(res=>{
        if(res.data.status===0){
          this.$parent.load(); 
        }
      })
      this.show = false;
    }
  }
};
</script>

<style>
</style>
